
const dao = require("../dao/user")
const response = require("../utils/response")
const { checkauth } = require("../utils/check");

/**
 * 更新用户信息
 * @param {*} data {user_id, secret_id, name, avatar}
 */
async function update_user(data) {
    let auth = await checkauth(data.secret_id, data.user_id);
    if (!auth) {
        return response.forbidden("权限错误");
    }
    await dao.update_user(data.user_id, data.name, data.avatar);
}

module.exports.update_user = update_user;
